<template>
	<view class="page" :style="themeColor">
		<view class="flex flex-direction flex-wrap align-stretch benben-position-layout flex download_flex_0"
			:style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx'}">
			<view class='flex flex-wrap align-center justify-between download_fd0_0' @tap.stop="handleJumpDiy"
				data-type="back" data-url="1">
				<view class='flex flex-wrap align-center download_fd0_0_c0' @tap.stop="handleJumpDiy" data-type="back"
					data-url="1">
					<image class='download_fd0_0_c0_c0' mode="aspectFit" :src='STATIC_URL+"30.png"'></image>
				</view>
				<view class='flex flex-wrap align-center'>
					<text class='download_fd0_0_c1_c0'>下载</text>
				</view>
				<view class='flex align-center justify-end download_fd0_0_c2'>
				</view>
			</view>

		</view>
		<view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
		<!---flex布局flex布局开始-->
		<view class="flex flex-wrap align-end benben-flex-layout download_flex_1">
			<view class='flex flex-wrap align-center justify-around flex-sub download_fd1_0'>
				<view class='flex flex-wrap align-center justify-center download_fd1_0_c0' @tap.stop="isIos">
					<image class='download_fd1_0_c0_c0' mode="aspectFill" :src='STATIC_URL+"31.png"'></image>
					<text class='download_fd1_0_c0_c1'>iPhone下载</text>
				</view>
				<view class='flex flex-wrap align-center justify-center download_fd1_0_c1' @tap.stop="isAndroid">
					<image class='download_fd1_0_c1_c0' mode="aspectFill" :src='STATIC_URL+"153.png"'></image>
					<text class='download_fd1_0_c1_c1'>Android下载</text>
				</view>
			</view>
		</view>
		<!---flex布局flex布局结束-->
		
		<view v-if="shareShow" class="share">
			<benben-popup v-model="shareShow" mode="top" :mask-close-able="false">
				<view class="share-popup">
					<image class="share-img" :src='STATIC_URL+"152.png"' mode="aspectFill"></image>
				</view>
			</benben-popup>
		</view>

	</view>
</template>
<script>
	export default {
		components: {},


		data() {
			return {
				shareShow: false,
				downloadInfo: {
					android_url: '',
					ios_url: ''
				}
			};
		},
		computed: {
			themeColor() {
				return this.$store.getters.themeColor
			},

		},
		watch: {},
		onLoad(options) {
			this.getDownload();
		},
		onUnload() {

		},
		onReady() {

		},
		onShow() {

		},
		onHide() {

		},
		onResize() {

		},
		onPullDownRefresh() {

		},
		onReachBottom(e) {

		},
		onPageScroll(e) {

		},
		methods: {
			// 获取下载链接  post6444e97d4f83a
			getDownload() {
				this.$api.post(global.apiUrls.post6444e97d4f83a, {
					
				}).then(res => {
					console.log(res);
					if (res.data.code == 1) {
						this.downloadInfo = res.data.data;
					} else {
						this.$message.info(res.data.msg);
					}
				})
			},
			
			// 下载ios
			isIos() {
				if (uni.getSystemInfoSync().platform != 'ios') {
					this.$message.info('请选择Android下载');
					return;
				}
				if (!this.downloadInfo.ios_url) {
					this.$message.info('未获取到下载链接，请稍后再试');
					return;
				}
				if(this.isWeiXin()) {
					this.shareShow = true;
				} else {
					window.open(this.downloadInfo.ios_url);
					return;
				}
			},
			// 下载安卓
			isAndroid() {
				if (uni.getSystemInfoSync().platform != 'android') {
					this.$message.info('请选择iPhone下载');
					return;
				}
				if (!this.downloadInfo.android_url) {
					this.$message.info('未获取到下载链接，请稍后再试');
					return;
				}
				if(this.isWeiXin()) {
					this.shareShow = true;
				} else {
					window.open(this.downloadInfo.android_url);
					return;
				}
			},
			// 判断是否在微信浏览器
			isWeiXin() {
			    var ua = window.navigator.userAgent.toLowerCase();
			    console.log(ua);//mozilla/5.0 (iphone; cpu iphone os 9_1 like mac os x) applewebkit/601.1.46 (khtml, like gecko)version/9.0 mobile/13b143 safari/601.1
			    if (ua.match(/MicroMessenger/i) == 'micromessenger') {
			        return true;
			    } else {
			        return false;
			    }
			},
		}
	};
</script>
<style lang="scss" scoped>
	.page {
		width: 100vw;
		overflow-x: hidden;
		min-height: calc(100vh - var(--window-bottom));
		background: transparent;
		background-size: 100% 100% !important;
		background: url(~@/static/images/29.png) no-repeat, transparent;
	}

	.download_flex_0 {
		background: #fff;
		width: 750rpx;
		height: 88rpx;
		overflow: hidden;
		z-index: 10;
		top: 0rpx;
		background-size: 100% auto !important;
	}

	.download_fd0_0_c2 {
		padding: 0rpx 0rpx 0rpx 0rpx;
		width: 200rpx;
	}

	.download_fd0_0_c1_c0 {
		font-size: 36rpx;
		font-weight: 500;
		color: #333333;
	}

	.download_fd0_0_c0_c0 {
		width: 30rpx;
		height: 30rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
	}

	.download_fd0_0_c0 {
		width: 200rpx;
	}

	.download_fd0_0 {
		padding: 0rpx 32rpx 0rpx 32rpx;
		line-height: 88rpx;
	}

	.download_flex_1 {
		// background: url(~@/static/images/29.png) no-repeat, transparent;
		// background-size: 100% auto !important;
		position: fixed;
		bottom: 48rpx;
		width: 100%;
	}

	.download_fd1_0_c1_c1 {
		color: #2A2A2A;
		font-size: 28rpx;
		font-weight: 500;
		line-height: 40rpx;
	}

	.download_fd1_0_c1_c0 {
		width: 25rpx;
		height: 31rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
		margin: 0rpx 10rpx 0rpx 0rpx;
	}

	.download_fd1_0_c1 {
		background: rgba(255, 255, 255, 1);
		width: 330rpx;
		height: 72rpx;
		border-radius: 36rpx 36rpx 36rpx 36rpx;
		background-size: 100% auto !important;
	}

	.download_fd1_0_c0_c1 {
		color: #2A2A2A;
		font-size: 28rpx;
		font-weight: 500;
		line-height: 40rpx;
	}

	.download_fd1_0_c0_c0 {
		width: 25rpx;
		height: 31rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
		margin: 0rpx 10rpx 0rpx 0rpx;
	}

	.download_fd1_0_c0 {
		background: rgba(255, 255, 255, 1);
		width: 330rpx;
		height: 72rpx;
		border-radius: 36rpx 36rpx 36rpx 36rpx;
		background-size: 100% auto !important;
	}

	.download_fd1_0 {
		margin: 0rpx 0rpx 58rpx 0rpx;
	}
	
	.share {
		// /deep/.fu-drawer-top {
		// 	background: transparent !important;
		// }
		.share-popup {
			background: transparent;
			padding: 32rpx 16rpx 0;
			
		}
		.share-img {
			width: 100%;
			height: 520rpx;
			// float: right;
		}
	}
</style>